package com.hotacorp.opencloud.logservice.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hotacorp.opencloud.common.mybatisplus.PageData;
import com.hotacorp.opencloud.common.mybatisplus.Query;

import com.hotacorp.opencloud.logservice.dao.SysLogDao;
import com.hotacorp.opencloud.logservice.entity.SysLogEntity;
import com.hotacorp.opencloud.logservice.service.SysLogService;

/**
 * 日志服务接口实现类
 * @author lwg
 *
 */
@Service("sysLogService")
public class SysLogServiceImpl extends ServiceImpl<SysLogDao, SysLogEntity> implements SysLogService {

    @Override
    public PageData queryPage(Map<String, Object> params) {
    	QueryWrapper<SysLogEntity> query= new QueryWrapper<SysLogEntity>();
		String key = (String) params.get("key");
		if (StringUtils.isNotEmpty(key)) {
			query.like("module", key);
			query.or().eq("username", key);
		}
    	query.orderByDesc("createtime");
        IPage<SysLogEntity> page = this.page(
                new Query<SysLogEntity>().getPage(params),
                query
        );

        return new PageData(page);
    }

}